# This dockerfile uses php7 image
# VERSION 1.0
# Author: zhaojianhui
# Command format: Instruction [arguments / command] ..

FROM php:7.3-fpm

#ARG APT_MIRROR=httpredir.debian.org

# init php extension
RUN apt-get clean && apt-get update && apt-get install -y \
        libfreetype6-dev \
        libjpeg62-turbo-dev \
        libmcrypt-dev \
        libxml2-dev \
        wget

#Add libzip
ENV LIB_ZIP libzip-1.2.0
RUN wget https://nih.at/libzip/$LIB_ZIP.tar.gz -O /tmp/$LIB_ZIP.tar.gz \
    && cd /tmp/ \
    && tar -zxvf $LIB_ZIP.tar.gz \
    && cd $LIB_ZIP \
    && ./configure && make && make install \
    && rm -rf /tmp/$LIB_ZIP/ /tmp/$LIB_ZIP.tar.gz \
    && cp /usr/local/lib/libzip/include/zipconf.h /usr/local/include/zipconf.h

# Add memcached
RUN apt-get install -y libmemcached-dev
ENV PHP_MEMCACHED 3.1.3
RUN wget https://codeload.github.com/php-memcached-dev/php-memcached/tar.gz/v$PHP_MEMCACHED -O /tmp/php-memcached-$PHP_MEMCACHED.tar.gz \
    && cd /tmp/ \
    && tar -zxvf php-memcached-$PHP_MEMCACHED.tar.gz \
    && cd /tmp/php-memcached-$PHP_MEMCACHED \
    && phpize \
    && ./configure \
    && make && make install \
    && docker-php-ext-enable memcached \
    && rm -rf /tmp/php-memcached-$PHP_MEMCACHED /tmp/php-memcached-$PHP_MEMCACHED.tar.gz

# Add phpredis
ENV PHP_REDIS 4.3.0
RUN wget https://codeload.github.com/phpredis/phpredis/tar.gz/$PHP_REDIS -O /tmp/phpredis-$PHP_REDIS.tar.gz \
    && cd /tmp \
    && tar -zxvf phpredis-$PHP_REDIS.tar.gz \
    && cd /tmp/phpredis-$PHP_REDIS \
    && phpize \
    && ./configure \
    && make && make install \
    && docker-php-ext-enable redis \
    && rm -rf /tmp/phpredis-$PHP_REDIS /tmp/phpredis-$PHP_REDIS.tar.gz

RUN docker-php-ext-install -j$(nproc) bcmath shmop sysvsem pcntl sockets xmlrpc zip soap gettext opcache \
    && docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ --with-freetype-dir \
    && docker-php-ext-install -j$(nproc) gd \
    && docker-php-ext-install mysqli pdo_mysql

# 配置文件更改
COPY ./conf /usr/local/etc/php